
export interface QueryCondition {
    class_identifiers?: StringCondition[],
    attributes?: AttributeCondition[],
    relations?: ClassRelationCondition[],
    expression?: QueryConditionExpression,
    orders?: OrderItem[],
    page_size?: number,
    page?: number,
}

export interface QueryConditionExpression {
    operator: LogicalOperatorType,
    left_expression?: QueryConditionExpression,
    right_expression?: QueryConditionExpression,
    left?: string,
    value?: string,
    values?: string[],
}

export interface AttributeCondition {
    name: string,
    operator: ComparsionOperator,
    value: string,
    values?: string[],
}

export interface ClassRelationCondition {
    conditions?: RelationCondition,
    attributes?: AttributeCondition[],
    class_conditions?: QueryCondition,
}

//[]
export interface QueryExtention {
    class_selector: { [key: string]: [string, QueryCondition, QueryExtention?] }
}

export interface OrderItem {

}

export interface QueryExtention {

}

export interface RelationTypeCondition {

}

export interface RelationCondition {
    class_identifier?: string,
    relation_identifier?: string,
    direction?: 'reverse' | 'obverse',
    related_at?: string,
    related_type?: 'keys' | 'class',
}

export interface StringCondition {
    operator: ComparsionOperator,
    value: string,
}

export enum StringOperator {
    Equal = "equal"
}

export enum ComparsionOperator {
    Contains = "contains",
    NotContains = "not contains",
    StartWith = "start with",
    EndWith = "end with",
    Is = "is",
    IsNot = "is not",
    Empty = "empty",
    NotEmpty = "not empty",
    Equal = "=",
    NotEqual = "≠",
    LargerThan = ">",
    LessThan = "<",
    LargerThanOrEqual = "≥",
    LessThanOrEqual = "≤",
    IsNull = "is null",
    IsNotNull = "is not null",
    In = "in",
    NotIn = "not in",
    NotallOfIn = "all of",
    Exists = "exists",
    NotExists = "not exists",
}

export enum LogicalOperator {
    And = "and",
    Or = "or",
}

export enum BitOperator {
    And = "&",
    Or = "|",
}

export type LogicalOperatorType = LogicalOperator | { 'bit-operator': BitOperator }

export interface QueryOptions {

}


export interface DeleteCondition {
    attributes?: Array<AttributeCondition>,
    relations?: Array<ClassRelationCondition>,
}

export interface UpdateCondition {
    attributes?: Array<AttributeCondition>,
    relations?: Array<ClassRelationCondition>,
}


export interface DeleteOptions {
    primary_key?: string,
}

export interface UpdateOptions {
    upsert?: boolean,
    primary_key?: string,

}

